package com.ycrlkj.android.modulescore.main.viewmodel;

import android.annotation.SuppressLint;

import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class VehicleRegisterViewModel extends ViewModel {

    public MutableLiveData<String> photo;

    public MutableLiveData<String> getPhoto() {
        if (photo == null) {
            photo = new MutableLiveData<>();
            photo.setValue("");
        }
        return photo;
    }

    public MutableLiveData<String> brandName;

    public MutableLiveData<String> getBrandName() {
        if (brandName == null) {
            brandName = new MutableLiveData<>();
            brandName.setValue("");
        }
        return brandName;
    }

    public MutableLiveData<String> modelName;

    public MutableLiveData<String> getModelName() {
        if (modelName == null) {
            modelName = new MutableLiveData<>();
            modelName.setValue("");
        }
        return modelName;
    }

    public MutableLiveData<String> drivingCode;

    public MutableLiveData<String> getDrivingCode() {
        if (drivingCode == null) {
            drivingCode = new MutableLiveData<>();
            drivingCode.setValue("");
        }
        return drivingCode;
    }

    public MutableLiveData<String> transportationCode;

    public MutableLiveData<String> getTransportationCode() {
        if (transportationCode == null) {
            transportationCode = new MutableLiveData<>();
            transportationCode.setValue("");
        }
        return transportationCode;
    }

    public MutableLiveData<String> plateNum;

    public MutableLiveData<String> getPlateNum() {
        if (plateNum == null) {
            plateNum = new MutableLiveData<>();
            plateNum.setValue("");
        }
        return plateNum;
    }


    /* #region ========================= 车牌颜色 开始 ====================== */
    public MutableLiveData<int[]> plateColorValueArr;
    public MutableLiveData<String[]> plateColorTextArr;
    public MutableLiveData<Integer> plateColorPosition;
    public MutableLiveData<String> plateColorText;

    public MutableLiveData<int[]> getPlateColorValueArr() {
        if (plateColorValueArr == null) {
            plateColorValueArr = new MutableLiveData<>();
            plateColorValueArr.setValue(new int[0]);
        }
        return plateColorValueArr;
    }

    public MutableLiveData<String[]> getPlateColorTextArr() {
        if (plateColorTextArr == null) {
            plateColorTextArr = new MutableLiveData<>();
            plateColorTextArr.setValue(new String[0]);
        }
        return plateColorTextArr;
    }

    public MutableLiveData<Integer> getPlateColorPosition() {
        if (plateColorPosition == null) {
            plateColorPosition = new MutableLiveData<>();
            plateColorPosition.setValue(0);
        }
        return plateColorPosition;
    }

    public MutableLiveData<String> getPlateColorText() {
        if (plateColorText == null) {
            plateColorText = new MutableLiveData<>();
            plateColorText.setValue("");
        }
        return plateColorText;
    }
    /* #endregion ====================== 车牌颜色 结束 ====================== */


    /* #region ========================= 车辆规格 开始 ====================== */
    public MutableLiveData<int[]> vehicleSpecificationValueArr;
    public MutableLiveData<String[]> vehicleSpecificationTextArr;
    public MutableLiveData<Integer> vehicleSpecificationPosition;
    public MutableLiveData<String> vehicleSpecificationText;

    public MutableLiveData<int[]> getVehicleSpecificationValueArr() {
        if (vehicleSpecificationValueArr == null) {
            vehicleSpecificationValueArr = new MutableLiveData<>();
            vehicleSpecificationValueArr.setValue(new int[0]);
        }
        return vehicleSpecificationValueArr;
    }

    public MutableLiveData<String[]> getVehicleSpecificationTextArr() {
        if (vehicleSpecificationTextArr == null) {
            vehicleSpecificationTextArr = new MutableLiveData<>();
            vehicleSpecificationTextArr.setValue(new String[0]);
        }
        return vehicleSpecificationTextArr;
    }

    public MutableLiveData<Integer> getVehicleSpecificationPosition() {
        if (vehicleSpecificationPosition == null) {
            vehicleSpecificationPosition = new MutableLiveData<>();
            vehicleSpecificationPosition.setValue(0);
        }
        return vehicleSpecificationPosition;
    }

    public MutableLiveData<String> getVehicleSpecificationText() {
        if (vehicleSpecificationText == null) {
            vehicleSpecificationText = new MutableLiveData<>();
            vehicleSpecificationText.setValue("");
        }
        return vehicleSpecificationText;
    }
    /* #endregion ====================== 车辆规格 结束 ====================== */


    /* #region ========================= 购买时间 开始 ====================== */
    public MutableLiveData<String[]> buyTimeArr;
    public MutableLiveData<String> buyTime;
    public MutableLiveData<Integer> buyTimePosition;

    public MutableLiveData<String[]> getBuyTimeArr() {
        if (buyTimeArr == null) {
            buyTimeArr = new MutableLiveData<>();

            String[] yearArr = new String[11];

            @SuppressLint("SimpleDateFormat")
            SimpleDateFormat sd = new SimpleDateFormat("yyyy");
            String thisYear = sd.format(new Date());

            for (int i = 0; i < 11; i++) {
                if (i == 0) {
                    yearArr[i] = "无";
                } else {
                    yearArr[i] = String.valueOf(Integer.parseInt(thisYear) + 1 - i);
                }
            }

            buyTimeArr.setValue(yearArr);
        }
        return buyTimeArr;
    }

    public MutableLiveData<String> getBuyTime() {
        if (buyTime == null) {
            buyTime = new MutableLiveData<>();
            buyTime.setValue("");
        }
        return buyTime;
    }

    public MutableLiveData<Integer> getBuyTimePosition() {
        if (buyTimePosition == null) {
            buyTimePosition = new MutableLiveData<>();
            buyTimePosition.setValue(0);
        }
        return buyTimePosition;
    }
    /* #endregion ====================== 购买时间 结束 ====================== */


}
